from rest_framework import serializers
from Vaccine.models import CategoryModels, VaccineModels

# 疫苗类别序列化器
class CategoryModelsSerializer(serializers.ModelSerializer):
    class Meta:
        model = CategoryModels
        fields = [
            'id', 
            'name', 
            'description'
        ]

# 疫苗信息序列化器
class VaccineModelsSerializer(serializers.ModelSerializer):
    category = CategoryModelsSerializer(many=True, read_only=True)

    class Meta:
        model = VaccineModels
        fields = [
            'id', 
            'name', 
            'author', 
            'reviewer', 
            'description', 
            'efficacy', 
            'contraindications', 
            'dosage', 
            'adverse_reactions', 
            'more_info', 
            'Category'
        ]